# -*- coding: UTF-8 -*-
"""
< member.py > Option
By AnpyD
"""

import member
import bs

normal_path = bs.getEnvironment()['systemScriptsDirectory'] + "/anm/member.py"

def add_admin(file=normal_path, client_id=""):
    """
    打开文件（此操作会清除文件内容）
    """
    admin_list = member.AdminList
    admin_list.append(str(client_id))
    ban_list = member.autoKickList
    FILE = open(file, "w+")
    Text = "AdminList = " + str(admin_list) + "\nautoKickList = " + str(ban_list)
    FILE.write(Text)
    FILE.close()
    print("账户系统 -> 成功添加一名管理员！")

def add_ban(file=normal_path, client_id=""):
    """
    打开文件（此操作会清除文件内容）
    """
    admin_list = member.AdminList
    ban_list = member.autoKickList
    ban_list.append(str(client_id))
    FILE = open(file, "w+")
    Text = "AdminList = " + str(admin_list) + "\nautoKickList = " + str(ban_list)
    FILE.write(Text)
    FILE.close()
    print("账户系统 -> 成功添加一名封禁玩家！")

def del_admin(file=normal_path, client_id=""):
    """
    打开文件（此操作会清除文件内容）
    """
    admin_list = member.AdminList
    admin_list.remove(str(client_id))
    ban_list = member.autoKickList
    FILE = open(file, "w+")
    Text = "AdminList = " + str(admin_list) + "\nautoKickList = " + str(ban_list)
    FILE.write(Text)
    FILE.close()
    print("账户系统 -> 成功删除一名管理员！")

def del_ban(file=normal_path, client_id=""):
    """
    打开文件（此操作会清除文件内容）
    """ 
    admin_list = member.AdminList
    ban_list = member.autoKickList
    ban_list.remove(client_id)
    FILE = open(file, "w+")
    Text = "AdminList = " + str(admin_list) + "\nautoKickList = " + str(ban_list)
    FILE.write(Text)
    print("账户系统 -> 成功删除一名封禁玩家！")
